package com.test.fileapplication.util;

import com.chad.library.adapter.base.entity.AbstractExpandableItem;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.util.ArrayList;
import java.util.List;

public class RemoteFileListSortByTime extends AbstractExpandableItem<RemoteFileListSortByTime.ByTimeFile> implements MultiItemEntity {

    private String showDate;
    private long time;
    private List<RemoteFile> list;

    public String getShowDate() {
        return showDate;
    }

    public void setShowDate(String showDate) {
        this.showDate = showDate;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public void setList(List<RemoteFile> list) {
        this.list = new ArrayList<>(list);
        for (RemoteFile file : list) {
            addSubItem(new ByTimeFile(file));
        }
    }

    public void addList(List<RemoteFile> list) {
        this.list.addAll(list);
        for (RemoteFile file : list) {
            addSubItem(new ByTimeFile(file));
        }
    }

    public void setList(List<RemoteFile> list, int itemType) {
        this.list = new ArrayList<>(list);
        for (RemoteFile file : list) {
            addSubItem(new ByTimeFile(file, itemType));
        }
    }

    public List<RemoteFile> getList() {
        return new ArrayList<>(list);
    }


    @Override
    public int getLevel() {
        return 0;
    }

    @Override
    public int getItemType() {
        return 0;
    }

    public static class ByTimeFile implements MultiItemEntity {


        private int itemType = 1;
        private RemoteFile file;

        public ByTimeFile(RemoteFile file) {
            this.file = file;
        }

        public ByTimeFile(RemoteFile file, int itemType) {
            this.file = file;
            this.itemType = itemType;
        }

        @Override
        public int getItemType() {
            return itemType;
        }

        public void setItemType(int itemType) {
            this.itemType = itemType;
        }

        public RemoteFile getFile() {
            return file;
        }

        public void setFile(RemoteFile file) {
            this.file = file;
        }
    }
}
